package student.aistar.day01;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class ReadMybatisConfigDemo {
    public static void main(String[] args) {
        //1. 获取mybatis-config.xml的主配置文件的字节输入流
        InputStream in = null;
        try {
            in = Resources.getResourceAsStream("mybatis-config.xml");


            //2. 构建一个SqlSessionFactory对象
            SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(in);

            //3. 获取session
            SqlSession session = factory.openSession();

            System.out.println(session);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
